{minimum_otp_vsn, "21.0"}.

{erl_opts, [debug_info,
            warn_export_all,
            warn_unused_vars,
            warn_shadow_vars,
            warn_unused_import,
            warn_obsolete_guard
           ]}.

{deps, [{cowlib, "2.13.0"},
        {gun, "2.1.0"},
        {getopt, "1.0.3"}
       ]}.

{escript_name, emqtt_cli}.
{escript_main_app, emqtt}.
{escript_incl_apps, [getopt,gun,cowlib]}.
{escript_emu_args, "%%! -smp true +K true +A 16 +P 200000 -env ERL_MAX_PORTS 100000 -env ERTS_MAX_PORTS 100000\n"}.
{escript_shebang, "#!/usr/bin/env escript\n"}.

{profiles,
    [{test,
        [{deps,
            [ {meck, "1.0.0"}
            , {emqx, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx"}}
            , {emqx_utils, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx_utils"}}
            , {emqx_durable_storage, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx_durable_storage"}}
            , {emqx_ds_backends, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx_ds_backends"}}
            , {emqx_ds_builtin_local, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx_ds_builtin_local"}}
            , {emqx_ds_builtin_raft, {git_subdir, "https://github.com/emqx/emqx", {tag, "e5.10.0"}, "apps/emqx_ds_builtin_raft"}}
            , {proper, "1.4.0"}
            , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.1"}}}
            , {sasl_auth, {git, "https://github.com/kafka4beam/sasl_auth.git", {tag, "v2.2.0"}}}
            ]},
         {erl_opts, [debug_info]},
         %% Define `TEST' in emqx to get empty `foreign_refereced_schema_apps'
         {overrides, [{add, emqx, [{erl_opts, [{d, 'TEST'}]}]}]}
        ]},
      {escript, []},
      {emqtt,
        [{relx,
          [{release, {emqtt, git_describe}, [
            kernel,
            sasl,
            crypto,
           public_key,
           asn1,
           syntax_tools,
           ssl,
           os_mon,
           inets,
           compiler,
           runtime_tools
         ]},
         {overlay_vars,["vars.config"]},
         {overlay, [
           {copy, "_build/escript/bin/emqtt_cli", "bin/emqtt_cli"},
           {copy,"bin/emqtt","bin/emqtt"},
           {template,"bin/emqtt","bin/emqtt"}
         ]},
         {include_src, false},
         {extended_start_script, false},
         {generate_start_script, false},
         {sys_config, false},
         {vm_args, false},
         {include_erts, true}
         ]}
        ]},
      {emqtt_pkg,
        [{relx,
        [{release, {emqtt, git_describe}, [
           kernel,
           sasl,
           crypto,
           public_key,
           asn1,
           syntax_tools,
           ssl,
           os_mon,
           inets,
           compiler,
           runtime_tools,
           quicer
         ]},
         {overlay_vars,["vars-pkg.config"]},
         {overlay, [
           {copy, "_build/escript/bin/emqtt_cli", "bin/emqtt_cli"},
           {copy,"bin/emqtt","bin/emqtt"},
           {template,"bin/emqtt","bin/emqtt"}
         ]},
         {include_src, false},
         {extended_start_script, false},
         {generate_start_script, false},
         {sys_config, false},
         {vm_args, false},
         {include_erts, true}
         ]

         }
        ]},
     %% test relup when emqtt is used as one dep app
     {emqtt_relup_test,
      [{relx,
        [{release, {emqtt, git_describe}, [
                                           kernel,
                                           sasl,
                                           crypto,
                                           public_key,
                                           asn1,
                                           syntax_tools,
                                           ssl,
                                           os_mon,
                                           inets,
                                           compiler,
                                           runtime_tools,
                                           emqtt
                                          ]},
         {include_src, false},
         {include_erts, true},
         {dev_mode, false},
         {overlay, [{copy, "{{ output_dir }}/ebin/emqtt.appup", "lib/{{ release }}/ebin/"}]}
        ]
       },
       {erl_opts, [{d, 'UPGRADE_TEST_CHEAT'}]}
      ]}

    ]}.

{cover_enabled, true}.
{cover_opts, [verbose]}.
{cover_export_enabled, true}.

{xref_checks, [undefined_function_calls]}.

{dialyzer, [
    {warnings, [unmatched_returns, error_handling]},
    {plt_location, "."},
    {plt_prefix, "emqtt_dialyzer"},
    {plt_apps, all_apps},
    {statistics, true},
    {plt_extra_apps, [quicer, getopt]}
]}.

{project_plugins, [{relup_helper,{git,"https://github.com/emqx/relup_helper", {tag, "2.0.0"}}}]}.
